package com.imooc.activiti.event;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 流程event
 * Creat by zyg
 */
public class CustomEventListerer implements ActivitiEventListener {
    private final static Logger LOGGER= LoggerFactory.getLogger(CustomEventListerer.class);

    @Override
    public void onEvent(ActivitiEvent activitiEvent) {
        ActivitiEventType eventType=activitiEvent.getType();
        if(ActivitiEventType.CUSTOM.equals(eventType)){
            LOGGER.info("用户自定义监听事件{} \t {}",activitiEvent,activitiEvent.getProcessInstanceId());
        }else if(ActivitiEventType.ACTIVITY_COMPLETED.equals(eventType)){
            LOGGER.info("流程结束{} \t {}",activitiEvent,activitiEvent.getProcessInstanceId());
        }
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }
}
